import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:get/get.dart';
import 'package:xin_he/routes/xin_he_routes.dart';
import 'package:xin_he/utils/xh_styles.dart';
void main() {
  runApp( const MyApp());
  SystemChrome.setPreferredOrientations([
    DeviceOrientation.portraitUp, //只能纵向
    DeviceOrientation.portraitDown, //只能纵向
  ]);
}


class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {

  final easyLoad = EasyLoading.init();

  @override
  void initState() {
    // TODO: implement initState
    super.initState();

    // Fluwx fluwx = Fluwx();
    // fluwx.registerApi(appId: "wxb2d5d6d2f6de380c",universalLink: "https://your.univerallink.com/link/");

  }

  @override
  Widget build(BuildContext context) {
    return RefreshConfiguration(
      headerBuilder: () => ClassicHeader(
        refreshingText: "数据加载中",
        refreshingIcon: SizedBox(
            width: 16,
            height: 16,
            child: CircularProgressIndicator(
              color: XinHeColor('#AFAFBC'),
              strokeWidth: 2,
            )),
        idleText: "",
        failedText: "刷新失败",
        releaseText: "",
        completeText: "加载完成",
      ),
      footerBuilder: () => const ClassicFooter(
        noDataText: "没有更多数据",
        loadingText: "加载中",
      ),
      enableLoadingWhenFailed: true,
      hideFooterWhenNotFull: !true,
      enableBallisticLoad: true,
      child: GetMaterialApp(
        // navigatorObservers: [widget.routeObserver],
        title: '芯禾',
        // locale: const Locale('zh', 'CH'),
        // localizationsDelegates: const [
        //   // GlobalCupertinoLocalizations.delegate,
        //   GlobalMaterialLocalizations.delegate,
        //   GlobalWidgetsLocalizations.delegate,
        // ],
        // supportedLocales: const [
        //   Locale('zh', 'CH'),
        // ],
        debugShowCheckedModeBanner: false,
        theme: ThemeData(
          // appBarTheme: AppBarTheme(systemOverlayStyle: SystemUiOverlayStyle.light),
          brightness: Brightness.light,
          primaryColor: Colors.white,
          textTheme: TextTheme(
            //To support the following, you need to use the first initialization method
              labelLarge: TextStyle(fontSize: 18)),
          //主题色
          colorScheme: const ColorScheme(
            primary: Colors.transparent,
            // primaryVariant: Colors.red,
            secondary: Colors.white,
            background: Colors.white,
            onBackground: Colors.white,
            onPrimary: Colors.white,
            // secondaryVariant: Colors.white,
            onSecondary: Colors.white,
            surface: Colors.white,
            onSurface: Colors.white,
            onError: Colors.white,
            brightness: Brightness.light,
            error: Colors.white,
            // all fields should have a value
          ),
        ),
        defaultTransition: Transition.rightToLeft,
        getPages: XinHePages.pages,
        initialRoute: XinHeRoutes.init,
        builder: (context, child) {
          child = easyLoad(context, child);
          // child = customToast(context, child);
          child = MediaQuery(
            //Setting font does not change with system font size
              data:
              MediaQuery.of(context).copyWith(textScaleFactor: 1.0),
              child: child);
          return child;
        },
      ),
    );
  }
}





